//package com.questionnaire.core.impl;
//
//
//import com.questionnaire.common.redis.RedisUtil;
//import com.questionnaire.core.SimpleCacheService;
//import org.apache.shiro.cache.Cache;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//
//import java.util.concurrent.TimeUnit;
//
///**
// * @Description：实现缓存管理服务
// */
//@Component
//public class SimpleCacheServiceImpl implements SimpleCacheService {
//
//    @Autowired
//    RedisUtil redisUtil;
//
//    @Override
//    public void creatCache(String cacheName, Cache<Object, Object> cache) {
//        RBucket<String> bucket = redisUtil.getObjRedis(cacheName);
//        bucket.trySet(ShiroRedissionSerialize.serialize(cache), ShiroUtil.getShiroSession().getTimeout()/1000, TimeUnit.SECONDS);
//    }
//
//    @Override
//    public Cache<Object, Object> getCache(String cacheName) {
//        RBucket<String> bucket = redissonClient.getBucket(cacheName);
//        return (Cache<Object, Object>) ShiroRedissionSerialize.deserialize(bucket.get());
//    }
//
//    @Override
//    public void removeCache(String cacheName) {
//        RBucket<String> bucket = redissonClient.getBucket(cacheName);
//        bucket.delete();
//    }
//
//    @Override
//    public void updateCache(String cacheName, Cache<Object, Object> cache) {
//        RBucket<String> bucket = redissonClient.getBucket(cacheName);
//        bucket.set(ShiroRedissionSerialize.serialize(cache), ShiroUtil.getShiroSession().getTimeout()/1000, TimeUnit.SECONDS);
//    }
//}
